package com.lgl.scsheader.system.service;

import com.lgl.scsapi.base.dao.DaoSupport;
import com.lgl.scsapi.system.model.PageData;
import com.lgl.scsapi.system.model.SysDictionaries;
import com.lgl.scsheader.system.model.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("dictionariesService")
public class DictionariesService{
	@Resource(name = "daoSupport")
	private DaoSupport dao;
	
	//新增
	public void save(PageData pd)throws Exception{
		dao.save("DictionariesMapper.save", pd);
	}
	
	//修改
	public void edit(PageData pd)throws Exception{
		dao.update("DictionariesMapper.edit", pd);
	}
	
	//通过id获取数据
	public PageData findById(PageData pd) throws Exception {
		return (PageData) dao.findForObject("DictionariesMapper.findById", pd);
	}
	
	//查询总数
	public PageData findCount(PageData pd) throws Exception {
		return (PageData) dao.findForObject("DictionariesMapper.findCount", pd);
	}
	
	//查询某编码
	public PageData findBmCount(PageData pd) throws Exception {
		return (PageData) dao.findForObject("DictionariesMapper.findBmCount", pd);
	}

	/**
	 * 查找字典数据集
	 * @param dicPd 查询参数
	 * @return 字典数据集
	 */
	public List<SysDictionaries> listDictionaries(PageData dicPd) {
		return (List<SysDictionaries>) dao.findForList("DictionariesMapper.listDictionaries", dicPd);
	}
	/**
	 * 查询数据字典的名称和编码
	 * @param page
	 * @return
	 * @throws Exception
	 */
	public List<PageData> pageDictlistPage(Page page) throws Exception {
		return (List<PageData>) dao.findForList("DictionariesMapper.pageDictlistPage", page);
	}
	//删除
	public void delete(PageData pd) throws Exception {
		dao.delete("DictionariesMapper.delete", pd);
	}

}